package com.bitmain.mmst.miner;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;

/**
 * 
 *
 * @author Richard - rui.wu@bitmain.com
 * @since 2016��7��4��
 *
 */
public abstract class AbstractScheduledTask {
	private List<TaskExecuteListener> listeners;
	
	public AbstractScheduledTask(){
		listeners = new ArrayList<TaskExecuteListener>();
	}
	
	public void addExecuteListener(TaskExecuteListener listener){
		if(CollectionUtils.isNotEmpty(listeners)){
			listeners = new ArrayList<TaskExecuteListener>();
		}
		listeners.add(listener);
	}
	
	public void executeDone(TaskExecuteEvent event){
		if(CollectionUtils.isNotEmpty(listeners)){
			for(TaskExecuteListener listener:listeners){
				listener.executeDone(event);
			}
		}
	}
}
